package com.clz.appdesign.databinding;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import com.clz.appdesign.myapp.R;
import com.clz.appdesign.myapp.databinding.ActivityDataBindingBinding;


/**
 * @author clz
 */
public class DataBindingActivity extends AppCompatActivity {

    private ActivityDataBindingBinding mDataBinding;
    private Presenter mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initDataBinding();
    }

    private void initDataBinding() {
        mPresenter=new Presenter();
        mDataBinding= DataBindingUtil.setContentView(this,R.layout.activity_data_binding);
        //将presenter对象赋予XML中的 data -> variable -> presenter
        mDataBinding.setPresenter(mPresenter);
    }



    public class Presenter {
        public String message = "~";

        public void baseDataBinding(){
            Toast.makeText(DataBindingActivity.this, mDataBinding.getContent.getText().toString(), Toast.LENGTH_SHORT).show();
        }

    }

}
